﻿Public Class FrmFormularios
    Private Sub btnAbrirFormulario_Click(sender As System.Object, e As System.EventArgs) Handles btnAbrirFormulario.Click
        Dim form As New FrmFormularioDePrueba()
        form.Show()
        'AddHandler form.FormClosed, AddressOf FormularioDePruebaCerrado
    End Sub

    Sub FormularioDePruebaCerrado(sender As Object, e As FormClosedEventArgs)
        MessageBox.Show("El formulario se cerró")
    End Sub

    Private Sub btnAbrirFormularioComoDialogo_Click(sender As System.Object, e As System.EventArgs) Handles btnAbrirFormularioComoDialogo.Click
        Dim form As New FrmFormularioDePrueba()
        If form.ShowDialog() = Windows.Forms.DialogResult.OK Then
            MessageBox.Show("OK: " & form.Respuesta, "Titulo", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Else
            MessageBox.Show("Cancel :(")
        End If
    End Sub

    Private Sub btnFormularioMDI_Click(sender As System.Object, e As System.EventArgs) Handles btnFormularioMDI.Click
        Dim form As New FrmFormularioDePrueba()
        form.MdiParent = Me
        form.Show()
    End Sub

    Private Sub btnFormularioMDIComoDialogo_Click(sender As System.Object, e As System.EventArgs) Handles btnFormularioMDIComoDialogo.Click
        Try
            Dim form As New FrmFormularioDePrueba()
            form.MdiParent = Me
            form.ShowDialog()
        Catch ex As Exception
            MessageBox.Show("No se puede abrir un formulario MDI como diálogo. Para abrir un diálogo, el formulario no debe tener un padre", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

    Private Sub itemEstiloCascada_Click(sender As System.Object, e As System.EventArgs) Handles itemEstiloCascada.Click
        LayoutMdi(MdiLayout.Cascade)
    End Sub

    Private Sub itemEstiloArrangeIcons_Click(sender As System.Object, e As System.EventArgs) Handles itemEstiloArrangeIcons.Click
        LayoutMdi(MdiLayout.ArrangeIcons)
    End Sub

    Private Sub itemEstiloTileHorizontal_Click(sender As System.Object, e As System.EventArgs) Handles itemEstiloTileHorizontal.Click
        LayoutMdi(MdiLayout.TileHorizontal)
    End Sub

    Private Sub itemEstiloTileVertical_Click(sender As System.Object, e As System.EventArgs) Handles itemEstiloTileVertical.Click
        LayoutMdi(MdiLayout.TileVertical)
    End Sub

End Class